// -*- Mode: C++ -*-
#ifndef SONG_H
#define SONG_H

#include <boost/signals2.hpp>
#include <vector>
#include <string>

class Track;
class Instrument;

class Song {
public:
     static const int BpmMin = 1;
     static const int BpmMax = 500;
     // onLoad signal template
     typedef boost::signals2::signal<void ()> OnLoad;

     Song(const std::string &name="");
     ~Song();
     const std::string &name();
     void setName(const std::string &name);

     int bpm();
     void setBpm(int bpm);
     int rowsPerBeat();
     void setRowsPerBeat(int rowsPerBeat);
     int patternLength();
     void setPatternLength(int length);

     void addTrack(Track *pTrack);
     void removeTrack(Track *pTrack);
     void removeTrackAt(int i);
     Track *trackAt(int i);
     int trackCount();
     void createTracks(int num);
     int patternCount();
     void setPatternCount(int count);

     void addInstrument(Instrument *pInstrument);
     void removeInstrument(Instrument *pInstrument);
     void removeInstrumentAt(int i);
     Instrument *instrumentAt(int i);
     int instrumentCount();

     int length();
     void setLength(int len);

     const std::string &fileName();
     void setFileName(const std::string &fileName);
     void save();
     void load();
     void clear();
     // connect to onLoad signal
     boost::signals2::connection onLoad(const OnLoad::slot_type &callback);

private:
     std::string m_name;
     std::vector<Track *> m_tracks;
     std::vector<Instrument *>m_instruments;
     int m_bpm;
     int m_rowsPerBeat;
     int m_patternLength;
     std::string m_fileName;
     OnLoad m_onLoad;
};

#endif
